package com.scau.phradmin.business.test.controller;


import com.scau.phradmin.business.contents.service.impl.*;
import com.scau.phradmin.business.user.service.impl.UserServiceImpl;

import com.scau.phradmin.domain.entity.Newhospital;
import com.scau.phradmin.domain.mapper.HospitalMapper;

import com.scau.phradmin.domain.mapper.VipContentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 用于测试thymeleaf模板
 * @author yuzhiyi
 * @date 2018/8/3 9:35
 */
@Controller
@RequestMapping("/test")
public class HelloController {

    @RequestMapping("/index")
    public String index(){
        return "index/index";
    }

	@RequestMapping("/hello")
	public String hello(ModelMap map){
		map.addAttribute("hello","怕老吉");
		return "hello";
	}

	@RequestMapping("/starter")
	public String starter(ModelMap map){
		return "test/starter";
	}

	@RequestMapping("/home")
	public String home(ModelMap map){
		map.addAttribute("view","manager/reportManage/transactionReport");
		return "manager/common/admin";

	}



	@RequestMapping("/addVipContent")
	public String addVipContent(ModelMap map){
		map.addAttribute("view","manager/userManage/vipContent/vip-content-add");
		return "manager/common/admin";
	}


	@Autowired
	private VipContentMapper vipContentMapper;
	@RequestMapping("/vipContentInfo")
	public String vipContentInfo(ModelMap map){
		map.addAttribute("view","manager/userManage/vipContent/vip-content-info");

		return "manager/common/admin";
	}

	/**
	 * 添加用户
	 * @param map
	 * @return
	 */
	@RequestMapping("/addUser")
	public String addUser(ModelMap map){
		map.addAttribute("view","manager/userManage/basicInfo/user-add");
		return "manager/common/admin";
	}
	@RequestMapping("/addNews")
	public String addNews(ModelMap map){
		map.addAttribute("view","manager/contentManage/publish/news-add");
		return "manager/common/admin";
	}
	@RequestMapping("/addMedicine")
	public String addDrug(ModelMap map){
		map.addAttribute("view","manager/contentManage/publish/medicine-add");
		return "manager/common/admin";
	}

	@RequestMapping("/addHospital")
	public String addHealthInfo(ModelMap map){
		map.addAttribute("view","manager/contentManage/publish/hospital-add");
		return "manager/common/admin";
	}
	/**
	 * 查看用户列表（分页）
	 */
	@Autowired
	private UserServiceImpl userService;
	@RequestMapping("/userInfo")
	public String userInfo(@RequestParam(value = "page",defaultValue = "1") Integer page, ModelMap map){
		map.addAttribute("view","manager/userManage/basicInfo/user-info");
		map.addAttribute("users",userService.selectAll(page).getValue());
		map.addAttribute("maxPage",userService.selectAll(page).getMaxPage());
		map.addAttribute("currentPage",userService.selectAll(page).getCurrentPage());
		return "manager/common/admin";
	}


	/**
	 * 查看新闻列表（分页）
	 */
	@Autowired
	private NewsServiceImpl newsService;
	@RequestMapping("/newsInfo")
	public String newsInfo(@RequestParam(value = "page",defaultValue = "1") Integer page, ModelMap map){
		map.addAttribute("view","manager/contentManage/list/news-info");
		map.addAttribute("news",newsService.SelectAll(page).getValue());
		map.addAttribute("maxPage",newsService.SelectAll(page).getMaxPage());
//		System.out.println();
		map.addAttribute("currentPage",newsService.SelectAll(page).getCurrentPage());
		return "manager/common/admin";
	}

	/**
	 * 查看医院列表（分页）
	 */
	@Autowired
	private HospitalServiceImpl hospitalService;
	@RequestMapping("/hospitalInfo")
	public String hospitalInfo(@RequestParam(value = "page",defaultValue = "1")Integer page, ModelMap map){
		map.addAttribute("view","manager/contentManage/list/hospital-info");
		map.addAttribute("hospitals",hospitalService.SelectAll(page).getValue());
		map.addAttribute("maxPage",hospitalService.SelectAll(page).getMaxPage());
		map.addAttribute("currentPage",hospitalService.SelectAll(page).getCurrentPage());

		return "manager/common/admin";
	}

	/**
	 * 查看药品列表（分页）
	 */
	@Autowired
	private MedicineDataServiceImpl medicineDataService;
	@RequestMapping("/medicineInfo")
	public String durgInfo(@RequestParam(value = "page",defaultValue = "1")Integer page, ModelMap map){
		map.addAttribute("view","manager/contentManage/list/medicine-info");
		map.addAttribute("medicines",medicineDataService.SelectAll(page).getValue());
		map.addAttribute("maxPage",medicineDataService.SelectAll(page).getMaxPage());
		map.addAttribute("currentPage",medicineDataService.SelectAll(page).getCurrentPage());
		return "manager/common/admin";
	}

    /**
     * 交易报表
     */
    @RequestMapping("/transactionReport")
    public String transactionReport(ModelMap map){
        map.addAttribute("view","manager/reportManage/transactionReport");
        return "manager/common/admin";
    }

    /**
     * 用户量报表
     */
    @RequestMapping("/userReport")
    public String userReport(ModelMap map){
        map.addAttribute("view","manager/reportManage/userReport");
        return "manager/common/admin";
    }

}
